package exporter;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;

import main.tokens;

public class ArrayListPrinter 
{
	private ArrayList<tokens> arlTokensArray;
	
	public ArrayListPrinter(ArrayList<tokens> pTArray)
	{
		arlTokensArray = pTArray;
	}
	
	public void printArray()
	{
		 try 
		 {
			 File f = new File("output//Array.txt");
			 f.createNewFile();
			 
			 BufferedWriter output = new BufferedWriter(new FileWriter(f));
			 String strTmp;
			 for (int i = 0; i < arlTokensArray.size(); i++)
			 {
				 strTmp = arlTokensArray.get(i).getToken() + "  [";
				 strTmp = strTmp + arlTokensArray.get(i).getState() + "]  ";
				 strTmp = strTmp + arlTokensArray.get(i).getLocation() + "  ";
				 strTmp = strTmp + arlTokensArray.get(i).getResult() ;
				 output.write(strTmp);
				 output.newLine();
			 }
			 
			 output.close();
		 }
		 catch (Exception e) 
		 {
		 	e.printStackTrace();
		 }
	}
	
	public void printArray(String pLoc, ArrayList<String> pFile)
	{
		 try 
		 {
			 File f = new File(pLoc);
			 f.createNewFile();
			 
			 BufferedWriter output = new BufferedWriter(new FileWriter(f));
			 String strTmp;
			 for (int i = 0; i < pFile.size(); i++)
			 {
				 strTmp = pFile.get(i);
				 output.write(strTmp);
				 output.newLine();
			 }
			 
			 output.close();
		 }
		 catch (Exception e) 
		 {
		 	e.printStackTrace();
		 }
	}
}
